<%@page import="javafx.scene.control.Alert"%>
<%@page import="henu.javaweb.dao.*"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@page import="java.util.ArrayList"%>
<%@page import="henu.javaweb.util.WebDbPool"%>
<%@page import="java.sql.*"%>
<%@page import="henu.javaweb.bean.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>学生信息管理系统</title>
<link rel="stylesheet" href="../../css/bootstrap.min.css">
<link rel="stylesheet" href="../../css/my.css">
<script type="text/javascript" src="../../js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="../../js/bootstrap.min.js"></script>
<script type="text/javascript">
	function move() {
		var qu = $("#college").val();

		switch (qu) {
		case "医学院":
			$("#major").removeAttr("disabled");
			$("#major").empty();
			$(
					"<option value='临床医学'>临床医学</option><option value='精神卫生'>精神卫生</option><option value='基础医学'>基础医学</option>")
					.appendTo("#major");
			break;
		case "计算机与信息工程学院":
			$("#major").removeAttr("disabled");
			$("#major").empty();
			$(
					"<option value='计算机科学与技术'>计算机科学与技术</option><option value='软件工程'>软件工程</option><option value='网络工程'>网络工程</option>")
					.appendTo("#major");
			break;
		case "物理与电子学院":
			$("#major").removeAttr("disabled");
			$("#major").empty();
			$(
					"<option value='通信工程'>通信工程</option><option value='电子信息科学与技术'>电子信息科学与技术</option><option value='测控技术与仪器'>测控技术与仪器</option>")
					.appendTo("#major");
			break;
		default:
			$("#major").attr("disabled", "disabled");
			$("#major").empty();
			$("<option>--请选择--</option>").appendTo("#major");
		}
	}
	if (window.name != "bencalie") {
		location.reload();
		window.name = "bencalie";
	} else {
		window.name = "";
	}
</script>
</head>
<body>
	<%@include file="header.jsp"%>
	<div class="container">
		<form class="form-inline myform" method="post"
			action="../../AddTeacherServlet" role="form">
			<h4>教师管理</h4>
			<div class="form-group">
				<input type="text" name="tid" placeholder="工号*" class="form-control">
			</div>
			<div class="form-group">
				<input type="text" name="tuser" placeholder="用户名*"
					class="form-control">
			</div>
			<div class="form-group">
				<input type="password" name="tpass" placeholder="密码*"
					class="form-control">
			</div>
			<div class="form-group">
				<input type="text" name="tfullname" placeholder="真实姓名*"
					class="form-control">
			</div>
			<div class="form-group">
				<select id="college" class="form-control" onchange="move()"
					name="college">
					<option>--请选择--</option>
					<option value="医学院">医学院</option>
					<option value="计算机与信息工程学院">计算机与信息工程学院</option>
					<option value="物理与电子学院">物理与电子学院</option>
				</select>
			</div>
			<div class="form-group">
				<select id="major" name="major" class="form-control"
					disabled="disabled">
					<option>--请选择--</option>
				</select>
			</div>
			<div class="checkbox">
				<label> <input type="checkbox" name="admin" />&nbsp;管理员
					&nbsp;
				</label>
			</div>
			<input type="submit" name="action"
				class="form-control btn btn-primary" value="添加" />
		</form>
		<table class="table table-striped table-bordered">
			<thread>
			<th>工号</th>
			<th>用户名</th>
			<th>全名</th>
			<th>院系</th>
			<th>专业</th>
			<th>是否为管理员</th>
			<th>操作</th>
			</thread>
			<tbody>
				<%
					TeacherDao tc = new TeacherDao();
					ArrayList<Teacher> teachers = new ArrayList<Teacher>();
					teachers = tc.getAllTeacher();
					for (int i = 0; i < teachers.size(); i++) {
				%>

				<tr>
					<td><%=teachers.get(i).getT_id()%></td>
					<td><%=teachers.get(i).getT_username()%></td>
					<td><%=teachers.get(i).getT_realname()%></td>
					<td><%=teachers.get(i).getT_faculty()%></td>
					<td><%=teachers.get(i).getT_major()%></td>
					<%
						if (teachers.get(i).getT_isAdmin() == true) {
					%>
					<td>√</td>
					<%
						} else {
					%>
					<td>×</td>
					<%
						}
					%>

					<td><a
						href="AlterTeacher.jsp?id=<%=teachers.get(i).getT_id()%>"> <span
							class="glyphicon glyphicon-edit"></span>
					</a>&nbsp;&nbsp;<%--  <a
						href="../../ResetPasswordServlet?id=<%=teachers.get(i).getT_id()%>" />
						<span class="glyphicon glyphicon-refresh"></span></a>&nbsp;&nbsp; --%> <a
						href="../../DeleteTeacherServlet?id=<%=teachers.get(i).getT_id()%>" />
						<span class="glyphicon glyphicon-trash"></span></a></td>
				</tr>
				<%
					}
				%>
			</tbody>
		</table>
	</div>
</body>
</html>